﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DelegateCommand.cs" company="ICodeFrog">
//   Max B.
// </copyright>
// <summary>
//   My simple ICommand implementation.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace FFMPEG_MKV2MP4
{
    using System;
    using System.Windows.Input;

    /// <summary>
    ///     The delegated command.
    /// </summary>
    public class DelegatedCommand : ICommand
    {
        #region Fields

        /// <summary>
        ///     The _action.
        /// </summary>
        private readonly Action action;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DelegatedCommand"/> class.
        /// </summary>
        /// <param name="action">
        /// The action or function to call.
        /// </param>
        public DelegatedCommand(Action action)
        {
            this.action = action;
        }

        #endregion

        #region Public Events

        /// <summary>
        ///     The can execute changed event, not used.
        /// </summary>
        public event EventHandler CanExecuteChanged
        {
            add
            {
            }

            remove
            {
            }
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// Checks if the command can executed.
        /// </summary>
        /// <param name="parameter">
        /// The parameter, not used.
        /// </param>
        /// <returns>
        /// Always returns true.
        /// </returns>
        public bool CanExecute(object parameter)
        {
            return true;
        }

        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="parameter">
        /// The parameter, not used.
        /// </param>
        public void Execute(object parameter)
        {
            this.action();
        }

        #endregion
    }
}